package com.szrt.chenpeng.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class LoginServlet extends HttpServlet {

	
	private static final long serialVersionUID = 2185780806301600405L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		response.setContentType("text/html;charset:utf-8");
		request.setCharacterEncoding("utf-8");
		String uname=request.getParameter("uname");
		String upass=request.getParameter("upass");
		HttpSession session=request.getSession();
		if(uname.equals("张无忌")&&upass.equals("123")){
			session.setAttribute("uname", uname);
			response.sendRedirect("C.jsp");
		}else {
			response.sendRedirect("<script type='text/javascript'>"+"alert('用户名密码输入错误，请重新登录！！！！');location.herf='ChenpengLogin.jsp'</script>");
		}
		
	}
}
